﻿package com.tangchao.client.sdh.sdhinterface
{
	import com.tangchao.client.sdh.control.SanDaHaControl;
	import com.tangchao.client.sdh.view.SanDaHaPanel;

	//此类为被动接口
	public class In
	{
		static private var _instance:In;
		
		public function In()
		{
			_instance = this;
		}
		
		static public function getInstance():In
		{
			if(!_instance)
			{
				_instance = new In;
			}
			return _instance;
		}
		
		//被动借口 用户进入坊间 username是进入的用户名 arr是已经进入房间 seatNo座位号的用户列表
		public function userEnterRoom(userName:String,seatNO:int, arr:Array):void
		{
			SanDaHaControl.getInstance().setMsg(userName+" enterRoom");
			SanDaHaPanel.getInstance().onUserEnterRoom(userName, arr);
		}
		
		//被动借口 用户离开坊间 username是离开的用户名 arr是已经进入房间的用户列表
		public function userLeaveRoom(userName:String, arr:Array):void
		{
			SanDaHaControl.getInstance().setMsg("userLeaveRoom:"+userName);
			SanDaHaPanel.getInstance().userLeaveRoom(userName, arr);
		}
		
		//被动借口 用户准备 username是准备的用户名 userArr-已经准备的用户 allReady是否全部准备
		public function userReady(userName:String, userArr:Array, allReady:Boolean):void
		{
			SanDaHaControl.getInstance().setMsg("userReady:"+userName);
			SanDaHaPanel.getInstance().onUserReady(userName, userArr, allReady);
		}
		
		//scoreName-设置底分的用户名 mode-模式（0-普通 1-心跳） modeName-设置模式的用户名 isAllAplly-是否全部同意底分设置 是的话可以开始发牌
		public function userSetScoreModel(scoreName:String, mode:int, score:int, modeName:String, isAllAplly:Boolean):void
		{
			SanDaHaControl.getInstance().setMsg("userSetScoreModel: "+mode+" "+mode);
			SanDaHaPanel.getInstance().userSetScoreModel(scoreName, mode, score, modeName, isAllAplly);
		}
		
		//发牌paiArr-到手的牌（int）  userName-下一叫分的用户 maxScore-下一个用户能叫的最大分数 mustBet-是否必须叫
		public function fapai(paiArr:Array, userName:String, maxScore:int, mustBet:Boolean):void
		{
			SanDaHaControl.getInstance().setMsg("发牌");
			SanDaHaPanel.getInstance().onFaPai(paiArr, userName, maxScore, mustBet);
		}
		
		//userName-叫分用户名 isJiaoFen-是否叫分 isJiaofenEnd-叫分过程是否结束 param-(若叫分过程结束 元素分别为 1-庄家用户名 2-底牌 3-若当前用户为庄家 则为拿到底牌后的牌 否则空）
		//（若叫分过程未结束 元素分别为下一个用户名 下一个能叫的最大分数 是否必须叫）
		public function userBet(userName:String, value:int, isJiaofenEnd:Boolean, param:Array):void
		{
			SanDaHaControl.getInstance().setMsg("叫分"+userName+isJiaofenEnd+ "叫分是否结束:"+isJiaofenEnd);
			SanDaHaPanel.getInstance().userBet(userName, value, isJiaofenEnd, param);
		}
		
		//zjName-庄家名 mainType叫的主牌(1-4 方片 红桃 草花 黑桃)
		public function userClaimMainCard(zjName:String, mainType:int):void
		{
			SanDaHaControl.getInstance().setMsg(zjName+" 选定主牌"+ mainType.toString());
			SanDaHaPanel.getInstance().createMainCard(zjName, mainType);
		}
		
		//userName-下牌用户名 cardArr-下的牌
		public function userPutBottomCards(userName:String, cardArr:Array):void
		{
			SanDaHaControl.getInstance().setMsg(userName+" 下底牌"+ cardArr.toString());
			SanDaHaPanel.getInstance().userPutBottomCards(userName, cardArr);
		}
		
		//userName-出牌用户名 cardArr-出的牌 cpRet-false为甩牌失败
		public function userPlayCards(userName:String, cardArr:Array, spRet:Boolean, stat:int, param:Array):void
		{
			// wait for impelement
			SanDaHaControl.getInstance().setMsg(userName+cardArr.toString());
			SanDaHaPanel.getInstance().userPlayCards(userName, cardArr, spRet, stat, param);
		}
		
		//userName-倒的用户名
		public function userDao(userName:String):void
		{
			SanDaHaControl.getInstance().setMsg("倒:"+userName);
			SanDaHaPanel.getInstance().onUserDao(userName);
		}
		
		//userName- 跟的用户名
		public function userGen(userName:String):void
		{
			SanDaHaControl.getInstance().setMsg("跟:"+userName);
			SanDaHaPanel.getInstance().onUserGen(userName);
		}
		
		//userName-反的用户名
		public function userFan(userName:String):void
		{
			SanDaHaControl.getInstance().setMsg("反:"+userName);
			SanDaHaPanel.getInstance().onUserFan(userName);
		}
		
		//是否隐藏倒
		public function disableDaoBtn(val:Boolean):void
		{
			SanDaHaControl.getInstance().setMsg("隐藏倒:"+val.toString());
			SanDaHaPanel.getInstance().hideDaoGenFang(1,val);
		}
		
		//是否隐藏跟
		public function disalbeGenBtn(val:Boolean):void
		{
			SanDaHaControl.getInstance().setMsg("隐藏跟:"+val.toString());
			SanDaHaPanel.getInstance().hideDaoGenFang(2,val);
		}
		
		//是否隐藏反
		public function disableFanBtn(val:Boolean):void
		{
			SanDaHaControl.getInstance().setMsg("隐藏反:"+val.toString());
			SanDaHaPanel.getInstance().hideDaoGenFang(3,val);
		}
		
		//是否不可出牌
		public function disablePlayBtn(val:Boolean):void
		{
			SanDaHaControl.getInstance().setMsg("禁止出牌");
			SanDaHaPanel.getInstance().isOutCard(false);
		}
		
		//userName-操作的玩家 val-true(托管  false(取消托管))
		public function userTuoGuan(userName:String, val:Boolean):void
		{
			SanDaHaControl.getInstance().setMsg("用户托管:"+userName+val.toString());
			SanDaHaPanel.getInstance().onUserTuoGuan(userName, val);
		}
		
		public function setHandCards(cardArr:Array):void
		{
			SanDaHaControl.getInstance().setMsg("设置用户手牌:"+cardArr.toString());
			SanDaHaPanel.getInstance().setHandCards(cardArr);
		}
		
		public function userSurrender(name:String, ret:Array):void
		{
			
		}
		
		//func-加载回调函数
		public function loadGame(func:Function):void
		{
			
		}
		
		//func-关闭回调函数
		public function destoryGame(func:Function):void
		{
			
		}
		
		public function gotUserList(userArr:Array):void
		{
			
		}
		
		public function gotTask(task:*):void
		{
			
		}
		
		public function gotMagicList(magicItem:*):void
		{
			
		}
		
		//userName-申请人  arr-是该房间中哪些人的好友 msg-申请信息
		public function userWaitingApproval(userName:String, arr:Array, msg:String):void
		{
			
		}
		
		//type-消息类型 msg-消息内容
		public function gotNotification(type:int, msg:String):void
		{
		}
		
		//设置用户的手牌
		public function setSelectedCards(cardArr:Array):void
		{
			SanDaHaPanel.getInstance().setSelectedCards(cardArr);
		}
		
		public function enterSetMode():void
		{
			SanDaHaControl.getInstance().setMsg("enterSetMode:");
			SanDaHaPanel.getInstance().enterSetMode();
		}
	}
}